package pro.spring.controller.backController;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import pro.spring.model.Information;
import pro.spring.vo.PaginationVo;


@Controller
@RequestMapping("information")
public class InformationController extends BaseController{
	
	private String local = "page/back/information/";
	
	private Integer pagesize = 10 ;
	
	private String defaultpath="redirect:bankuai.html";
	
	private PaginationVo<Information> pagelist ;
	
	@RequestMapping(value="bankuai.html",method=RequestMethod.GET)
	public String discussList(@RequestParam(value = "p", defaultValue = "1")Integer pagenum,ModelMap map,String key){
		if(key ==null || key ==""){
			pagelist =informationService.getAllPaginationInfo(pagenum, pagesize);
		}else{
			pagelist =informationService.getAllPaginationInfoByKey(key,pagenum, pagesize);
		}
		map.put("list", pagelist);
		map.put("key",key);
		System.out.println(pagelist.getList().size());
		return local+"information";
	}
	

	@RequestMapping(value="{id}.html",method=RequestMethod.GET)
	public String delete(@PathVariable int id,ModelMap map){
		informationService.deleteByPrimaryKey(id);
		return defaultpath;
	}
}